﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TP2
{
    public partial class EditBankForm : Form
    {
        int id_bank;
        string title;
        string bik;
        string inn;
        long capital;
        string founders;
        string type;
        BankClientForm Form;
        public EditBankForm(int idBank, string Title, string Bik, string Inn, long Capital, string Type, string Founders,BankClientForm bankForm)
        {
            id_bank = idBank;
            title = Title;
            bik = Bik;
            inn = Inn;
            capital = Capital;
            type = Type;
            founders = Founders;
            Form = bankForm;
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void EditBankForm_Load(object sender, EventArgs e)
        {
            textBoxTitle.Text = title;
            textBoxCapital.Text = capital.ToString();
            textBoxtype.Text = type;
            textBoxFounder.Text = founders;
            maskedTextBoxBik.Text = bik;
            maskedTextBoxInn.Text = inn;
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                title = textBoxTitle.Text;
                capital = Convert.ToInt64(textBoxCapital.Text);
                founders = textBoxFounder.Text;
                inn = maskedTextBoxInn.Text;
                bik = maskedTextBoxBik.Text;
                type = textBoxtype.Text;
                DBWorkClass dbWork = new DBWorkClass();
                dbWork.UpdateFromBank(id_bank, title, bik, inn, capital, type, founders);
                Form.RefresTable();
                this.Close();
            }
            catch (FormatException) { MessageBox.Show("ошибка во входных данных!"); }
        }
    }
}
